]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dbusServices/extensions: Use static class blocks for gtype registration
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 22 May 2025 01:22:49 +0000 (03:22 +0200)
committerMarge Bot <marge-bot@gnome.org>
Fri, 1 Aug 2025 08:57:44 +0000 (08:57 +0000)
Static class blocks are a more readable alternative to _classInit(),
provided we make sure to call registerClass() first.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3750>

js/dbusServices/extensions/extensionPrefsDialog.js

index f6061a9be6d2d7c34bb6818e83f401b192848e7c..c880031246691cb63065317e0c5f9851d36ee6a9 100644 (file)
@@ -7,12 +7,16 @@ import Gtk from 'gi://Gtk?version=4.0';
 
 import {formatError} from './misc/errorUtils.js';
 
-export const ExtensionPrefsDialog = GObject.registerClass({
-    GTypeName: 'ExtensionPrefsDialog',
-    Signals: {
+export class ExtensionPrefsDialog extends Adw.PreferencesWindow {
+    static [GObject.GTypeName] = 'ExtensionPrefsDialog';
+    static [GObject.signals] = {
         'loaded': {},
-    },
-}, class ExtensionPrefsDialog extends Adw.PreferencesWindow {
+    };
+
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(extension) {
         super({
             title: extension.metadata.name,
@@ -66,32 +70,32 @@ export const ExtensionPrefsDialog = GObject.registerClass({
 
         this.add(new ExtensionPrefsErrorPage(this._extension, e));
     }
-});
+}
 
-const ExtensionPrefsErrorPage = GObject.registerClass({
-    GTypeName: 'ExtensionPrefsErrorPage',
-    Template: 'resource:///org/gnome/Shell/Extensions/ui/extension-error-page.ui',
-    InternalChildren: [
+class ExtensionPrefsErrorPage extends Adw.PreferencesPage {
+    static [GObject.GTypeName] = 'ExtensionPrefsErrorPage';
+    static [Gtk.template] =
+        'resource:///org/gnome/Shell/Extensions/ui/extension-error-page.ui';
+
+    static [Gtk.internalChildren] = [
         'expander',
         'expanderArrow',
         'revealer',
         'errorView',
-    ],
-}, class ExtensionPrefsErrorPage extends Adw.PreferencesPage {
-    static _classInit(klass) {
-        super._classInit(klass);
+    ];
+
+    static {
+        GObject.registerClass(this);
 
-        klass.install_action('page.copy-error',
+        this.install_action('page.copy-error',
             null,
             self => {
                 const clipboard = self.get_display().get_clipboard();
                 clipboard.set(self._errorMarkdown);
             });
-        klass.install_action('page.show-url',
+        this.install_action('page.show-url',
             null,
             self => Gtk.show_uri(self.get_root(), self._url, Gdk.CURRENT_TIME));
-
-        return klass;
     }
 
     constructor(extension, error) {
@@ -157,4 +161,4 @@ const ExtensionPrefsErrorPage = GObject.registerClass({
             provider,
             Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
     }
-});
+}